package com.nucarf.bi.digtalize.bean;

import lombok.Data;

import java.math.BigDecimal;

@Data
public class GlobalBalance {

    private Long customer_number;
    private Integer source;
    private String company_name;
    private BigDecimal amount;
    private Long statTime;

    public SinkKafkaBean copyToSinkKafkaBean(String balanceTopic, String defaultCusCode) {
        SinkKafkaBean sinkBean = new SinkKafkaBean<GlobalBalance>();
        String cusCode;
        String companyName;
        Long customer_number = this.customer_number;
        if (customer_number == null || customer_number.intValue() == 0) {
            cusCode = defaultCusCode;
            companyName = "第三方";
        } else {
            cusCode = customer_number.toString();
            companyName = this.company_name;
        }
        sinkBean.setTopic(balanceTopic);
        sinkBean.setCus_code(cusCode);
        sinkBean.setSource(1);
        sinkBean.setTrade_time(this.statTime);
        PushBalance pushBalance = new PushBalance();
        pushBalance.setCus_code(cusCode);
        pushBalance.setSource(1);
        pushBalance.setCompany_name(companyName);
        pushBalance.setAmount(this.amount.setScale(4, BigDecimal.ROUND_HALF_UP));
        pushBalance.setTrade_time(this.statTime);
        sinkBean.setSendBean(pushBalance);
        return sinkBean;
    }
}
